# Contributor: Rdbo <rdbodev@gmail.com>
# Contributor: Fabricio Silva <hi@fabricio.dev>
# Maintainer: Nicolas Lorin <androw95220@gmail.com>
pkgname=rio
pkgver=0.1.17
pkgrel=0
pkgdesc="A hardware-accelerated GPU terminal emulator powered by WebGPU, focusing to run in desktops and browsers."
url="https://raphamorim.io/rio"
# loongarch64: blocked by libc crate
arch="all !s390x !loongarch64"
license="MIT"
# net: required to fetch rust dependencies
options="net"
depends="$pkgname-terminfo"
makedepends="cargo cargo-auditable cmake expat-dev freetype-dev fontconfig-dev libxcb-dev ncurses python3"
subpackages="$pkgname-doc $pkgname-terminfo"
source="$pkgname-$pkgver.tar.gz::https://github.com/raphamorim/rio/archive/refs/tags/v$pkgver.tar.gz"

# tests are too slow
case "$CARCH" in
	riscv64) options="$options !check";;
esac

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen --no-default-features --features=x11,wayland
	tic -e rio -x -o terminfo misc/rio.terminfo
}

check() {
	cargo test --release --frozen
}

package() {
	install -Dm755 target/release/rio "$pkgdir"/usr/bin/rio
	install -Dm644 terminfo/r/rio "$pkgdir"/usr/share/terminfo/r/rio

	# Install desktop files
	install -Dm644 misc/rio.desktop -t "$pkgdir"/usr/share/applications/
	install -Dm644 misc/logo.svg \
		"$pkgdir"/usr/share/icons/hicolor/scalable/apps/rio.svg

	install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}

terminfo() {
	amove usr/share/terminfo
}

sha512sums="
82e4e1d50e44a9c7d5cf274b0817ef844c3563f7c92e4045d6518029fe7374bb6d452c835889f5d93e2b0d7d89825e3dbef31c0fd6152977d7554e8dc323cbfc  rio-0.1.17.tar.gz
"
